package handler

import (
	"awesomeProject/app/request"
	"awesomeProject/app/verify"
	//"awesomeProject/global"
	"awesomeProject/util"

	//"awesomeProject/app/model"
	//"awesomeProject/app/request"
	"awesomeProject/app/response"
	"awesomeProject/app/service"
	//"awesomeProject/app/verify"
	"github.com/gin-gonic/gin"
	//"strconv"
)

type OrderProcessHandler struct{}

var (
	orderProcessSrv service.OrderProcessSrv
)

func (r *OrderProcessHandler) Pagination(ctx *gin.Context) {
	var req request.OrderProcessPagination
	_ = ctx.Bind(&req)
	// 表单验证
	if err := verify.OrderProcessPagination(&req); err != nil {
		response.Result(ctx, response.ErrInvalidParam.SetMsg(err.Error()))
		return
	}

	response.Result(ctx, orderProcessSrv.Pagination(req))
	return
}

func (r *OrderProcessHandler) Update(ctx *gin.Context) {
	var req []request.OrderProcessUpdate
	_ = ctx.Bind(&req)

	//buf := make([]byte, 1024)
	//n, _ := ctx.Request.Body.Read(buf)
	//postContent := string(buf[0:n])
	//global.LoggerOut(postContent)
	//
	//err := json.Unmarshal(buf[0:n], &req)
	//if err != nil {
	//	response.Result(ctx, response.ErrSystem.SetMsg(err.Error()))
	//	return
	//}

	response.Result(ctx, orderProcessSrv.Update(req, util.CurrentLogin(ctx)))
	return
}
